#!/usr/bin/python
#coding:utf-8

from collections import Counter
import sys

reload(sys)
sys.setdefaultencoding("utf-8")


def compare(srcPath,dstPath):
    srcFp = open(srcPath)
    dstFp = open(dstPath)
    srcLines = []
    repeatMap = {}
    print "start to remove \\n of srcLines"
    
    for line1 in srcFp.readlines():
        line1=line1.strip('\n')
        line1=line1.strip('"')
        # if repeatMap.has_key
        # sameCount = srcLines.count(line1)
        # if sameCount > 0:
        #     line1 = line1 + str(sameCount)
        srcLines.append(line1)
        # print line1

    print "end of remove \\n of srcLines"
    dstLines = []
    print "start to remove \\n of dstLines"
    for line2 in dstFp.readlines():
        line2=line2.strip('\n')
        line2=line2.strip('"')
        # sameCount = dstLines.count(line2)
        # if sameCount > 0:
        #     line2 = line2 + str(sameCount)
        dstLines.append(line2)
    print "end of remove \\n of dstLines"
    srcFp.close()
    dstFp.close()

    srcSet = set(srcLines)
    dstSet = set(dstLines)
    set3 = srcSet-dstSet
    set4 = dstSet-srcSet
    
    print "=============================================================="
    print "Following is srcSet-dstSet:"
    for s in set3:
        print "[srcSet - dstSet] = %s" % s
    print "=============================================================="
    print "Following is dstSet-srcSet:"
    for s in set4:
        print "[dstSet - srcSet] = %s" % s
    
    # print "=============================================================="
    # for item in srcSet:
    #     count = srcLines.count(item)
    #     if count > 1:
    #         print "[srcLines]%s repeat %d" % (item, count)
    # print "=============================================================="
    # for item in dstSet:
    #     count = dstLines.count(item)
    #     if count > 1:
    #         print "[dstLines]%s repeat %d" % (item, count)
            
    print "=============================================================="
    print "srcfile contains line %d, path=%s" % (len(srcLines), srcPath)
    print "dstfile contains line %d, path=%s" % (len(dstLines), dstPath)
    print "=============================================================="

    print "srcSet size: %d" % len(srcSet)
    print "dstSet size: %d" % len(dstSet)
    print "=============================================================="
    print "srcSet - dstSet size: %d" % len(set3)
    print "dstSet - srcSet size: %d" % len(set4)
    
    
if __name__ == '__main__':
    #combine("uimUser1.txt","uimUser2.txt") 
    compare("uimLogin.txt", "ccLogin.txt")
    # testMap = {}
    # print testMap.has_key("a")